﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace Assets.Scripts
{
   public class Spawner : MonoBehaviour
    {
        public GameObject list = new GameObject();
        List<GameObject> lists;
        public int count = 10;
       private float time = 2;
       private  float myTime = 2;
        public Vector3 spawnPosition;
       private float GetTime
        {
           get
            {
                return 2;
            }
        }
        // Use this for initialization
        void Start()
        {
            myTime = GetTime;
            lists = ObjectPool.instance.Create(list, count);
            InvokeRepeating("Moving", myTime, myTime);
        }

        void Moving()
        {
            for (int i = 0; i < lists.Count; i++)
            {
                if (!lists[i].activeInHierarchy)
                {
                    ObjectPool.instance.Spawn(lists[i], spawnPosition, Quaternion.identity);
                    break;
                }
            }
        }
    }
}
